$(function(){
	if($(".admin").height()<600){
		$('.nav-btn').height('50px').find('img').hide();
	}else{
		$('.nav-btn').height('150px').find('img').show();
	}
})
//	出入库列表
	var pageSize = 15;
	var currentPage = 3; 
	ajaxTest(currentPage);
	
	function ajaxTest(currentPage) {
		$.ajax({
				type:"post",
				url:serverIP+"/user/goodsIo/list",
				dataType:"json",
				xhrFields: {
	                withCredentials: true    // 设置sessionId相同
	            },
	            data: {page:currentPage,pageSize:pageSize},
				success:function (data) {
					if(data.code==0){
						let result=data.data.list.result;
						var strVar = "";
						result.map(function(u){
							if(u.type=="01"){
								var type="入库";
							}else{
								var type="出库";
							}
							strVar += "              <tr>";
						    strVar += "                <td id=\"id\">"+u.goodsIOId+"<\/td>\n";
						    strVar += "                <td>"+u.goodsName+"<\/td>\n";
						    strVar += "                <td>"+u.date+"<\/td>\n";
						    strVar += "                <td>"+u.brandName+"<\/td>\n";
						    strVar += "                <td>"+u.modelName+"<\/td>\n";
						    strVar += "                <td>"+u.colorName+"<\/td>\n";
						    strVar += "                <td>"+type+"<\/td>\n";
						    strVar += "                <td>"+u.supplier+"<\/td>\n";
						    strVar += "                <td>"+u.num+"<\/td>\n";
						    strVar += "                <td>"+u.unitName+"<\/td>\n";
						    strVar += "                <td>"+u.remark+"<\/td>\n";
						    strVar += "              <\/tr>";
						})
						$('.print-tbody').html(strVar);
					//分页
						$("#page").paging({
							pageNo: data.data.list.curPage,
							totalPage: data.data.list.totalPage,
							totalSize: data.data.list.totalRow,
							callback: function(currentPage) {
								ajaxTest(currentPage); 
							}
						});
					}else{
						alert(data.msg);
						window.location.href="login.html";
					}/*if-End*/
				}
		})
	}
$('#selectOk').click(function(){
	//	搜索后的出入库列表
	var dateBegin=$('#beginTime').val();
	var dateEnd=$('#finishTime').val();
	var type=$('#type').val();
	$.ajax({
			type:"post",
			url:serverIP+"/user/goodsIo/list",
			dataType:"json",
			xhrFields: {
                withCredentials: true    // 设置sessionId相同
            },
            data: {dateBegin:dateBegin,dateEnd:dateEnd,type:type},
			success:function (data) {
				if(data.code==0){
					let result=data.data.list.result;
					var strVar = "";
					result.map(function(u){
						if(u.type=="01"){
							var type="入库";
						}else{
							var type="出库";
						}
						strVar += "              <tr>";
					    strVar += "                <td id=\"id\">"+u.goodsIOId+"<\/td>\n";
					    strVar += "                <td>"+u.goodsName+"<\/td>\n";
					    strVar += "                <td>"+u.date+"<\/td>\n";
					    strVar += "                <td>"+u.brandName+"<\/td>\n";
					    strVar += "                <td>"+u.modelName+"<\/td>\n";
					    strVar += "                <td>"+u.colorName+"<\/td>\n";
					    strVar += "                <td>"+type+"<\/td>\n";
					    strVar += "                <td>"+u.supplier+"<\/td>\n";
					    strVar += "                <td>"+u.num+"<\/td>\n";
					    strVar += "                <td>"+u.unitName+"<\/td>\n";
					    strVar += "                <td>"+u.remark+"<\/td>\n";
					    strVar += "              <\/tr>";
					})
					$('.print-tbody').html(strVar);
				//分页
					$("#page").paging({
						pageNo: data.data.list.curPage,
						totalPage: data.data.list.totalPage,
						totalSize: data.data.list.totalRow,
						callback: function(currentPage) {
							ajaxTest(currentPage); 
						}
					});
				}else{
					alert(data.msg);
				}/*if-End*/
			}
		})
})
$('.select-div>p').hide();
$('.search-btn').click(function(){
	$('.select-div>p').toggle();
})
//监听浏览器窗口变化
window.onresize = function(){
	var bodyH=$("body").height();
	$(".leftbar").height(bodyH-45+"px");
	$(".content").height(bodyH-45+"px");
	$(".admin").height($(".content").height()-45+"px");
	if($(".admin").height()<600){
		$('.nav-btn').height('50px').find('img').hide();
	}else{
		$('.nav-btn').height('150px').find('img').show();
	}
}
//时间戳转换
$('#beginTime').each(function() {
	var a = new Calendar({
		targetCls: $(this),
		type: 'yyyy-mm-dd',
		wday: 2
	})
});
$('#finishTime').each(function() {
	var a = new Calendar({
		targetCls: $(this),
		type: 'yyyy-mm-dd',
		wday: 2
	})
});
